/**
 * 
 */
package com.hungdev.component;

import java.util.Calendar;

import android.app.Dialog;
import android.app.DialogFragment;
import android.app.TimePickerDialog;
import android.content.Context;
import android.os.Bundle;
import android.text.format.DateFormat;
import android.widget.TimePicker;

/**
 * @author Ken
 * 
 */
public class TimePickerPopup extends DialogFragment implements
		TimePickerDialog.OnTimeSetListener {

	private Calendar c;
	private int hour;
	private int minute;
	private Context context;

	/**
	 * @param context
	 */
	public TimePickerPopup(Context context) {
		super();
		this.context = context;
	}

	@Override
	public Dialog onCreateDialog(Bundle savedInstanceState) {
		// Use the current time as the default values for the picker
		c = Calendar.getInstance();
		hour = c.get(Calendar.HOUR_OF_DAY);
		minute = c.get(Calendar.MINUTE);

		// Create a new instance of TimePickerDialog and return it
		return new TimePickerDialog(getActivity(), this, hour, minute,
				DateFormat.is24HourFormat(getActivity()));
	}

	public void onTimeSet(TimePickerDialog view, int hourOfDay, int minute) {
		// Do something with the time chosen by the user
		String hour = String.valueOf(hourOfDay);
		String min = String.valueOf(minute);
		if (hourOfDay < 10) {
			hour = "0" + hourOfDay;
		}
		if (minute < 10) {
			min = "0" + minute;
		}
		/*if (flagFrom) {
			fromHour = hourOfDay;
			fromMin = minute;
			btnFrom.setText("" + hour + ":" + min);
			flagFrom = false;
		}
		if (flagTo) {
			toHour = hourOfDay;
			toMin = minute;
			btnTo.setText("" + hour + ":" + min);
			flagTo = false;
		}*/
	}


	@Override
	public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
		// TODO Auto-generated method stub
		
	}
}